package com.tools;

public class FomartTool {

	public static String formatMMSS(long time) {

		long mm = time / (60 * 1000);
		long ss = time % (60 * 1000);
		ss /= 1000;

		String tmp = "";

		if (mm < 10) {
			tmp += "0";
		}
		tmp += (mm + ":");

		if (ss < 10) {
			tmp += "0";
		}
		tmp += "" + ss;
		return tmp;

	}

	public static String format4(String text) {

		float k = Float.parseFloat(text);
		float tmp = 0;

		String format = "";

		if (k < 1000) {
			return text;
		}

		if (k < 1000 * 1000) {
			tmp = k / 1000f;
			format = tmp + "";
			if (format.length() < 4) {
				format += "0000";
			}
			format = format.substring(0, 4) + "K";
		} else {
			tmp = k / (1000 * 1000);
			format = tmp + "";
			if (format.length() < 4) {
				format += "0000";
			}
			format = format.substring(0, 4) + "M";
		}

		if (format.indexOf(".") == 3) {
			format = format.replace(".", "");
		}
		return format;
	}

}
